import { ACCESS_ENUM } from './accessEnum'

/**
 @param loginUserAccess
 @param needAccess 需要的权限
 @return boolean 有无权限
 **/


const checkAccess = (loginUserAccess: number, needAccess: number) => {
    if (loginUserAccess === ACCESS_ENUM.NOT_LOGIN) return needAccess === ACCESS_ENUM.NOT_LOGIN
    if (loginUserAccess === ACCESS_ENUM.USER) {
        if (needAccess === ACCESS_ENUM.ADMIN || needAccess === ACCESS_ENUM.NOT_LOGIN) return false
    }
    return !(needAccess === ACCESS_ENUM.NOT_LOGIN && loginUserAccess === ACCESS_ENUM.ADMIN)
}

export default checkAccess
